<!-- *Author: 黄旗, *Date: 2020-08-04 15:45:59 -->
<template>
    <Modal v-model='modal' title='删除站点' :mask-closable='false' @on-cancel='canceledit' draggable>
        <p class="ivu-mb-8" style="padding-left:50px;">当前站点数据库被共用，暂时无法删除。</p>
        <p class="ivu-mb-8" style="padding-left:50px;"> 如需删除，请先修改以下引用站点：</p>
        <div style="text-align: center;line-break: anywhere;color:#ffad33;font-weight: bolder;"   v-for="(item,index) in list" :key="index">
            <div>【{{item}}】</div>
        </div>
        <p style="text-align: center;">是否要删除{{title}}关联的FTP、数据库、站点目录</p>
        <!-- <p style="text-align: center;"><font color="#ffad33" style="line-break: anywhere;">删除本站点，将会同步删除本站点对应的源码、数据库等</font></p> -->
        <div style="display: flex;justify-content: center;">
            <div>
                <Checkbox v-model="single" disabled class="ivu-mt-16 checkline">FTP(本地和线上)</Checkbox>
                <Checkbox  v-model="delete_local_dir" class="ivu-mt-16  checkline" >本地站点目录</Checkbox>

            </div>
            <div>
                <Checkbox v-model="delete_db"  class="ivu-mt-16 ivu-ml-16 checkline" :disabled="+db_type===4">数据库</Checkbox>
                <Checkbox  v-model="delete_online_dir" class="ivu-mt-16  ivu-ml-16 checkline" >线上站点目录</Checkbox>
            </div>

        </div>
        <!-- <p style="text-align: center;font-weight: bolder;" v-if="list&&list.length>0">当前站点存在共用站点，请先修改以下站点</p>
        <div style="text-align: center;line-break: anywhere;color:#ffad33;font-weight: bolder;"   v-for="(item,index) in list" :key="index">
            <div>【{{item}}】</div>
        </div> -->
        <!-- <p class="ivu-mt-16" style="text-align: center;font-weight: bolder;" v-if="list&&list.length>0">当前站点数据库被[<span style="line-break:anywhere;color:#ffad33;font-weight: bolder;" >{{domain}}</span>]所共用，暂时无法删除</p>
        <p class="ivu-mt-8" style="text-align: center;font-weight: bolder;" v-if="list&&list.length>0">如需删除本站点，请先修改站点[<span style="line-break:anywhere;color:#ffad33;font-weight: bolder;" >{{domain}}</span>]</p> -->
        <div slot='footer'>
            <Button type='error' :loading="subloading" v-if="list&&list.length===0" @click='submitedit'>{{subloading?'站点删除中':'确定删除'}}</Button>
            <Button @click='canceledit'>取消</Button>
        </div>
    </Modal>
</template>

<script>
    import { siteindexdelete, checkDelete } from '@api/httpsetting'
    export default {
        name: '',
        components: {},

        data () {
            return {
                modal: false,
                subloading: false,
                title: '',
                list: null,
                modalparams: { id: '' },
                single: true,
                delete_db: true,
                delete_local_dir: true,
                delete_online_dir: true,
                db_type: '',
                domain: ''
            };
        },
        // created () {
        //     this.initial()
        // },
        /* 函数方法集合 */
        methods: {
            /* @函数功能: 初始化 */
            initial (row) {
                this.modalparams.id = row.id
                this.title = row.domain
                this.db_type = row.db_type
                this.delete_db = +row.db_type !== 4
                this.modal = true
                this.getcheck()
            },
            canceledit () {
                this.modal = false
            },
            getcheck () {
                checkDelete({ id: this.modalparams.id }).then((res) => {
                    this.list = res.domain
                    this.domain = res.domain ? res.domain.join(',') : ''
                }).catch(() => {

                })
            },
            submitedit () {
                this.subloading = true
                const params = {
                    id: this.modalparams.id,
                    delete_db: this.delete_db == true ? 1 : 0,
                    delete_local_dir: this.delete_local_dir == true ? 1 : 0,
                    delete_online_dir: this.delete_online_dir == true ? 1 : 0
                }
                siteindexdelete(params).then(() => {
                    this.$Message.success('删除成功')
                    this.$emit('askData')
                    this.modal = false
                    this.subloading = false
                }).catch(() => {
                    this.subloading = false
                })
            }
        }
    }
</script>
<style scoped>
.checkline{
    display: block;
}
/deep/.ivu-checkbox-disabled .ivu-checkbox-inner{
    border-color:#3d3d41;
    background-color:#28282b
}
</style>
